<!-- 培训档案 -->
<template>
  <a-card :bordered="false">
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="档案编号">
              <j-input placeholder="请输入档案编号" v-model="queryParam.finalNo"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="申请人">
              <select-user-by-dep placeholder="请选择申请人" v-model="queryParam.handlerId" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="培训开始日期">
              <j-date
                placeholder="请选择培训开始日期"
                v-model="queryParam.trainingStartDate"
                date-format="YYYY-MM-DD"
                style="width: 100%" />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="培训结束日期">
              <j-date
                placeholder="请选择培训结束日期"
                v-model="queryParam.trainingEndDate"
                date-format="YYYY-MM-DD"
                style="width: 100%" />
            </a-form-item>
          </a-col>

          <!-- <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="培训日期">
              <a-range-picker
                v-model="createTimeRange"
                format="YYYY-MM-DD"
                :placeholder="['开始日期', '日期']"
                @change="onCreateTimeChange" />
            </a-form-item>
          </a-col> -->
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="取得证书名称">
              <j-input placeholder="请输入证书名称" v-model="queryParam.certificateName"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="档案状态">
              <j-dict-select-tag
                type="list"
                v-model="queryParam.status"
                dictCode="training_status"
                placeholder="请选择档案状态" />
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="变更状态">
              <j-dict-select-tag
                type="list"
                v-model="queryParam.changeStatus"
                dictCode="change_status"
                placeholder="请选择变更状态" />
            </a-form-model-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button
                type="primary"
                @click="createTimeRange = [], searchReset()"
                icon="reload"
                style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button
        type="primary"
        icon="download"
        @click="handleExportXls('培训档案')"
        :disabled="isDisabledAuth('erpHrInductionBill:export')">导出</a-button> -->
      <!-- <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import" :disabled="isDisabledAuth('erpHrInductionBill:import')">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <!--<j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <a-popover title="自定义列" trigger="click" placement="leftBottom">
        <template slot="content">
          <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
            <a-row>
              <template v-for="(item, index) in defColumns">
                <template v-if="item.key != 'rowIndex' && item.dataIndex != 'action'">
                  <a-col :span="12" :key="index"><a-checkbox :value="item.dataIndex">{{ item.title }}</a-checkbox></a-col>
                </template>
              </template>
            </a-row>
          </a-checkbox-group>
        </template>
        <a style="float: right;"><a-icon type="setting" :style="iconStyle" /></a>
      </a-popover>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
          selectedRowKeys.length
        }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: '100%' }"
        :components="draggableComponent"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        class="j-table-force-nowrap"
        :customRow="customRow"
        @change="handleTableChange">
        <a slot="finalNo" slot-scope="text, record" @click="getDetail(record)">{{ text }}</a>

        <template slot="status" slot-scope="status">
          <a-badge :status="status | statusTypeFilter" :text="status | statusFilter" />
        </template>
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            height="25px"
            alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;" />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
      </a-table>
    </div>
  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction, postAction } from '@/api/manage'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin'
import SelectHrApplyBillInput from '@/views/scy/components/SelectHrApplyBillInput'
import JSearchSelect from '@views/erp/hr/apply/modules/JSearchSelect.vue'
import SelectTeamInput from '@/views/scy/components/SelectTeamInput';
import moment from 'moment'
import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
import { filterMultiDictText, initDictOptions } from '@comp/dict/JDictSelectUtil';
export default {
  name: 'ErpHrInductionBillList',
  mixins: [JeecgListMixin, mixinDevice, DisabledAuthFilterMixin],
  components: {
    SelectHrApplyBillInput,
    JSearchSelect,
    SelectTeamInput,
    SelectUserByDep
  },
  data() {
    return {
      description: '培训档案',
      // 表头
      columns: [],
      // 列设置
      settingColumns: [],
      // 列定义
      defColumns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '档案编号',
          align: 'center',
          width: 200,
          dataIndex: 'finalNo',
          scopedSlots: { customRender: 'finalNo' },
          ellipsis: true
        },
        {
          title: '培训类型',
          align: 'center',
          dataIndex: 'trainingCategory_dictText',
          width: 100,
          ellipsis: true
        },
        {
          title: '申请人',
          align: 'center',
          dataIndex: 'createBy_dictText',
          width: 110,
          ellipsis: true
        },
        {
          title: '申请部门',
          align: 'center',
          dataIndex: 'applyDeptId_dictText',
          width: 130,
          ellipsis: true
        },
        {
          title: '申请时间',
          align: 'center',
          dataIndex: 'createTime',
          width: 160,
          ellipsis: true
        },
        {
          title: '培训开始日期',
          align: 'center',
          dataIndex: 'trainingStartDate',
          width: 160,
          ellipsis: true
        },
        {
          title: '培训结束日期',
          align: 'center',
          dataIndex: 'trainingEndDate',
          width: 160,
          ellipsis: true
        },
        {
          title: '取得证书名称',
          align: 'center',
          dataIndex: 'certificateName',
          width: 200,
          ellipsis: true
        },
        {
          title: '变更状态',
          align: 'center',
          dataIndex: 'changeStatus_dictText',
          width: 100,
          ellipsis: true
        },
        {
          title: '档案状态',
          align: 'center',
          dataIndex: 'status_dictText',
          width: 100,
          ellipsis: true
        }
      ],
      url: {
        list: '/api/erp/hr/training/erpHrTrainingFinal/list',
        exportXlsUrl: '/api/erp/hr/training/erpHrTrainingFinal/exportXls',
        importExcelUrl: '/api/erp/hr/training/erpHrTrainingFinal/importExcel'
      },
      dictOptions: {},
      superFieldList: [],
      createTimeRange: []
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    }
  },
  methods: {
    searchReset() {
      this.queryParam = {}
      this.loadData(1)
    },
    onCreateTimeChange(dateString) {
      this.queryParam.arrivalTime_begin = moment(dateString[0]).format('YYYY-MM-DD');
      this.queryParam.arrivalTime_end = moment(dateString[1]).format('YYYY-MM-DD');
    },
    // 查看详情
    getDetail(record) {
      this.$router.push({
        path: `/erp/hr/training/ErpHrTrainingApplyFinallListDetail/${record.lastBillId},${record.id}`
      })
    },
    handleDetail: function (record) {
      const _path = this.$route.path
      if (_path.startsWith('/hmhb/') || _path.startsWith('/scy/') || _path.startsWith('/imp/')
        || _path.startsWith('/erp/')) {
        this.$router.push({
          path: `${_path}Detail/${record.lastBillId},${record.id}`
        })
      } else {
        this.$refs.modalForm.edit(record);
        this.$refs.modalForm.title = '详情';
        this.$refs.modalForm.disableSubmit = true;
      }
    },
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: 'string', value: 'applyId', text: '应聘申请单', dictCode: '' })
      fieldList.push({ type: 'string', value: 'applyUnit', text: '入职单位', dictCode: '' })
      fieldList.push({ type: 'sel_depart', value: 'departmentId', text: '入职部门' })
      fieldList.push({ type: 'string', value: 'positionId', text: '入职岗位', dictCode: '' })
      fieldList.push({ type: 'string', value: 'inductionType', text: '入职类型', dictCode: '' })
      fieldList.push({ type: 'string', value: 'teamId', text: '所属团队', dictCode: '' })
      fieldList.push({ type: 'string', value: 'probationership', text: '试用期', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'conversionSalary', text: '转正薪资', dictCode: '' })
      fieldList.push({ type: 'string', value: 'trialSalary', text: '试用薪资', dictCode: '' })
      fieldList.push({ type: 'string', value: 'feeTeamId', text: '费用所属团队', dictCode: '' })
      fieldList.push({ type: 'string', value: 'insuredUnit', text: '参保单位', dictCode: '' })
      fieldList.push({ type: 'string', value: 'insuredBase', text: '参保基数（元）', dictCode: '' })
      fieldList.push({ type: 'string', value: 'workType', text: '工作类型', dictCode: '' })
      fieldList.push({ type: 'date', value: 'arrivalTime', text: '到岗时间' })
      fieldList.push({ type: 'BigDecimal', value: 'practicingGold', text: '执业金（元）', dictCode: '' })
      fieldList.push({ type: 'string', value: 'remark', text: '备注', dictCode: '' })
      fieldList.push({ type: 'Text', value: 'attachments', text: '附件', dictCode: '' })
      fieldList.push({ type: 'string', value: 'bpmStatus', text: '流程状态', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
